package com.hrms.patient.controller;
import com.hrms.patient.core.page.TableDataInfo;
import com.hrms.patient.domain.Patient;
import com.hrms.patient.Service.PatientService;
import com.hrms.patient.core.controller.BaseController;
import com.hrms.patient.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController


public class PatientController extends BaseController {

    @Autowired
    PatientService patientService;
    /*新增患者*/

    @PostMapping("/patient")
    public AjaxResult save(Patient patient){
        //返回值
        return toAjax(patientService.save(patient));

    }
    /*删除患者*/

    @DeleteMapping("/patient")
    public AjaxResult delete(@RequestParam List<Integer> list){

        return toAjax(patientService.delete(list));
    }


    /*查询功能*/
   /* @GetMapping("/patient")
    public AjaxResult list(){
        log.info("查询患者基本信息");
        List<Patient> patientList = patientService.list();
        return AjaxResult.success("测试用例成功","数据对象");

    }*/

    /*更新患者信息*/

    @PutMapping("/patient")
    public AjaxResult update(@RequestBody Patient patient){

        return toAjax( patientService.update(patient));
    }


    @GetMapping("/patient")
    public TableDataInfo list( String name, String phone){
        startPage();
        List<Patient> list = patientService.selectPatient(name, phone);
        return getDataTable(list);
    }

}
